package com.xhlj.security.captcha;

import lombok.Data;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class CaptchaLoginAuthenticationToken extends AbstractAuthenticationToken {
    private String code;
    private String phone;
    private UserPrinciple user;

    public CaptchaLoginAuthenticationToken(Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
    }

    public CaptchaLoginAuthenticationToken(String phone, String code, Collection<? extends GrantedAuthority> authorities) {
        super(authorities);
        this.code = code;
        this.phone = phone;
    }

    @Override
    public Object getCredentials() {
        return null;


    }

    @Override
    public Object getPrincipal() {
        Map res = new HashMap();
        res.put("phone", phone);
        res.put("code", code);
        return res;
    }

    @Override
    public String getName() {
        return this.phone;
    }
}
